<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" th:href="@{/favicon.png}" type="image/x-icon">
    <link rel="stylesheet" type="text/css" th:href="@{/res/layui/css/layui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/res/adminui/dist/css/admin.css}">
    <script type="text/javascript" th:src="@{/res/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/res/jquery/jquery.js}"></script>
</head>
<body>
<div class="layui-card" id="editRoleModal" >
    <div class="layui-card-body">
        <form class="layui-form" id="dataForm">
            <div class="layui-form-item">
                <label class="layui-form-label" for="jobName">名称：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="jobName" name="jobName" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="invokeTarget">invokeTarget：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="invokeTarget" name="invokeTarget" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="cronExpression">cron：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="cronExpression" name="cronExpression" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="concurrency">并发：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="concurrency" name="concurrency" />
                </div>
                <label class="layui-form-label" for="status">状态：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="status" name="status" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="remark">备注：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="remark" name="remark" />
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-normal" onclick="save()">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="close()">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" th:inline="javascript">
    const contextPath = [[${#httpServletRequest.getContextPath()}]];
</script>
<script type="text/javascript">
    function save() {
        const formData = $("#dataForm").serializeArray()
        const formObject = {}
        for (const item in formData) {
            formObject[formData[item].name] = formData[item].value
        }
        $.ajax({
            type: 'post',
            url: contextPath + '/quartz/add',
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(formObject),
            datatype: "json",
            success: function (data) {
                if (data.code === 1) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        close()
                    }, 3000)
                } else {
                    console.log(data);
                    layer.msg(data.msg);
                }
            }
        });
        return false
    }
    function close() {
        const index = parent.layer.getFrameIndex(window.name)
        parent.layer.close(index)
    }
</script>
</body>
</html>